Do [sprite stopActionByTag: kTag]; working differently for different CCActions ?

Posted by srikanth rongali on Stack Overflow See other posts from Stack Overflow or by srikanth rongali
Published on 2010-04-13T10:51:50Z Indexed on 2010/04/13 10:52 UTC
Read the original article Hit count: 366

Filed under:
|

//prog 1

-(void)gameLogic:(ccTime)dt  
{    
id actionMove = [CCMoveTo actionWithDuration:1.0 position:ccp(windowSize.width/2-400, actualY)];
[actionMove setTag:6];
[self schedule:@selector(update:)];
[hitBullet runAction:actionMove];
}

-(void)update:(ccTime)dt
{
if ( (CGRectIntersectsRect(hitRect, playerRect)) )
  {
   [[[self getActionByTag:6] retain] autorelease];
   [hitBullet stopActionByTag: 6]; 
  }      
}

//prog 2

-(void)gameLogic:(ccTime)dt
{
  id actionMove = [CCMoveTo actionWithDuration:1.0 position:ccp(windowSize.width/2-400, actualY)];
  id hitBulletAction = [CCSequence actionWithDuration:(intervalforEnemyshoot)];
  id hitBulletSeq = [CCSequence actions: hitBulletAction, actionMove, nil];
  [hitBulletSeq setTag:5];
[self schedule:@selector(update:)]; 
  [hitBullet runAction:hitBulletSeq];
}  

-(void)update:(ccTime)dt
{
if ( (CGRectIntersectsRect(hitRect, playerRect)) )
  {
   [[[self getActionByTag:5] retain] autorelease];
   [hitBullet stopActionByTag: 5]; 
  }      
}

While prog1 is working prog2 is not working ? I think the both are same. But why the two stopActions are working differently in two prog1 and prog2 ? I mean the actions are stopped in prog1 but the actions are not stopping in prog2 ? thank You.

© Stack Overflow or respective owner

Related posts about cocos2d-iphone

Related posts about cocoa-touch